#include<bits/stdc++.h>
using namespace std;
int k,m,n,l[200010],r[200010],x[200010];
string s;
int main(){
	freopen("copy.in","r",stdin);
	freopen("copy.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>k>>m>>s>>n;
	s=" "+s;
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i]>>x[i];
		l[i]++;
	}
	for(int i=1;i<=k;i++){
		int now=i;
		for(int j=n;j>=1;j--)
			if(x[j]<now){
				if(x[j]+r[j]-l[j]+1>=now) now=now-x[j]+l[j]-1;
				else now-=r[j]-l[j]+1;
			}
		cout<<s[now];
	}
	return 0;
}
